The present invention relates in general to antialiasing techniques for computer graphics systems, and in particular to antialiasing using hybrid supersampled/multisampled pixel data.
Display devices, such as monitor screens, produce images using an array of small-size picture elements (“pixels”), each having a solid color. The color of each pixel is independently controllable so that an arbitrary image can be produced on the display device. In many instances, pixel color is determined using a graphics processing system that receives image data to be rendered from an application program. The image data generally includes position, location, size, and color information for a number of simple polygons (e.g., triangles) referred to as “primitives,” of which the image is composed. The graphics processing system rasterizes the image data by sampling the primitives at a number of predetermined sample locations (e.g., a point corresponding to the center of each pixel), thereby generating a shading value (also referred to as a “color value”) for each pixel. These shading values are stored in a frame buffer that is periodically scanned out to a display device, thereby producing a viewable image.
In general, the shading value for a pixel is determined according to the color of a primitive that covers the pixel. For instance, FIG. 1A illustrates four pixels 101, 102, 103, 104 of a display and two primitives 120, 130 to be rendered. A sample location 105, 106, 107, 108 is illustrated for each pixel, and the shading value of each pixel is determined based on the primitive(s) that cover the sample location. Shading values can be determined using numerous well-known techniques, such as constant shading, interpolation of shading values for each vertex, Gouraud shading, Phong shading, and shading computed using a user-written fragment program.
When two or more primitives cover the same sample location, color is generally based on the visible one (typically the one in front). In many systems, front-to-back ordering of primitives involves “depth buffering.” That is, the objects making up the image are rasterized one at a time, with no particular requirement as to order. A depth value for each sampling location, representing the distance from the nearest primitive to the view point, is stored along with the shading value obtained from the nearest primitive. For instance, in FIG. 1A, object 130 covers all of sample locations 105, 106, 107, 108. If primitive 130 is rasterized first, the shading and depth values of primitive 130 are stored for each sample location. Primitive 120 covers sample locations 105, 107 but not sample locations 106, 108. When primitive 120 is rasterized, the shading and depth values for sample locations 105, 107 are modified, but the shading and depth values for sample locations 106, 108 are not. Depth values are also useful for other purposes, such as texture mapping.
Regardless of particular techniques used, rasterization can lead to “aliasing,” i.e., undesirable visual artifacts that result from the finite spacing of the sample locations. For instance, in FIG. 1A, primitive 120 only partially covers each of pixels 101, 102, 103, 104. Sampling at locations 105, 106, 107, 108 causes pixels 101 and 103 to take on the color of primitive 120, while pixels 102 and 104 take on the color of primitive 130. As a result, the edge of primitive 120 will appear jagged, not smooth. Aliasing can also produce other artifacts, such as apparent irregularities in regular patterns.
To reduce these artifacts, various “anti-aliasing” techniques have been developed. Most of these techniques rely on some form of “oversampling,” i.e., providing multiple shading values per pixel. Prior to display, the shading values for each pixel are blended, or “downfiltered,” to arrive at a final color value for that pixel. Two conventional oversampling techniques are “supersampling” and “multisampling.”
Supersampling can be done using the techniques described above, except that each pixel is sampled at multiple locations, as illustrated in FIG. 1B. In this example, pixel 101 has four sample locations 111, 112, 113, and 114. At each location, 111, 112, 113, 114, a shading value and a depth value are computed, as if each location were in a different pixel. In the case of pixel 101, the shading and depth values for locations 113 and 114 are determined from primitive 120, while the shading and depth values at locations 111 and 112 are determined from primitive 130. Upon downfiltering of the four shading values, pixel 101 has a color that blends the respective colors of primitives 120 and 130. Pixel 102 will be a different blended color, as it has two sample locations 121, 122 that are covered by primitive 130 and two sample locations 123, 124 that are covered by primitive 120. In this way, the apparent jaggedness of the edge of primitive 120 is smoothed.
Supersampling, however, significantly increases the computational burden by increasing the number of shading computations that are required for each pixel. It is generally desirable to allow the color of primitive 120 to vary as a function of position within the primitive, so that the shading value at location 113 generally is not the same as at location 114, even though both locations are covered by primitive 120. Consequently, each additional sample location within a pixel requires an additional computation of the shading value. To do the fourfold supersampling illustrated in FIG. 1B quadruples the number of shading computations required, placing very heavy demands on the rendering system.
Multisampling, illustrated in FIG. 1C, is an alternative technique that provides some antialiasing benefit while considerably reducing the computational burden. In multisampling, depth and coverage for pixel 101 are determined at each of a number of depth sample locations (also referred to as “depth locations”) 111, 112, 113, 114, as in supersampling. Unlike supersampling, however, the shading is computed only once per pixel (e.g., at location 105). This one shading value is stored along with the depth value for each depth location 111, 112, 113, 114 that is covered by the primitive. Subsequent primitives are rasterized as if the previous primitive had been supersampled. For example, in FIG. 1C, if primitive 130 is rasterized first, the shading value for pixel 101 is determined at location 105. Since all four depth locations 111, 112, 113, 114 are covered by primitive 130, the shading value at location 105 is stored for each depth location, together with the depth value. When primitive 120 is rasterized, a shading value for pixel 101 is again determined at location 105. Primitive 120, which is in front of primitive 130, covers depth locations 113, 114, but not depth locations 111, 112. Thus, the stored shading values for depth locations 113, 114 are replaced with the shading value for primitive 130 determined at location 105; the depth values are also replaced. The shading values for depth locations 111, 112, which are not covered by primitive 120, are not changed. Upon downfiltering of the shading values for the four sample locations, pixel 101 will have a color value that blends the respective colors of primitives 120 and 130. If the shading location is outside a primitive, as is the case for shading location 106 of pixel 102 (which is outside primitive 120), then the color is typically determined outside the primitive. This can introduce inaccuracies for depth locations that are inside the primitive; for instance, depth locations 123, 124 may have an incorrect shading value. Such inaccuracies generally have only minor effect on image quality. In order to avoid these inaccuracies, some multisampling solutions perturb the shading location so that it lies within the primitive.
For a given number of depth sample locations per pixel, multisampling generally has a lower computational burden than supersampling, since determining depth and coverage is usually significantly simpler than determining shading; however, supersampling can improve the antialiasing effect for pixels that are not at the edge of a primitive when the shading of the primitive has high spatial frequencies, such as sharp specular highlights.
It would therefore be desirable to provide an antialiasing method that has antialiasing capability comparable to supersampling with a given number of samples per pixel without the added computational burden associated with supersampling.